home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5176 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.0 KB  |  59 lines

  1. Newsgroups: comp.lang.c++
  2. Path: usinternet.com!not-for-mail
  3. From: Scott Jibben <sjibben@usinternet.com>
  4. Subject: Re: Pointers to member functions HOW?
  5. Message-ID: <31127EE6.30E3@usinternet.com>
  6. Date: Fri, 02 Feb 1996 15:15:18 -0600
  7. Organization: Jibben Software
  8. X-Mailer: Mozilla 2.0b6a (WinNT; I)
  9. MIME-Version: 1.0
  10. References: <31067074.6B53@compuserve.com> <4e9nh8$iji@news2.ios.com> <31113B7A.4C82@usinternet.com> <4et7ns$1ur@news2.ios.com>
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13.  
  14. Vlastimil Adamovsky wrote:
  15. > Scott Jibben <sjibben@usinternet.com> wrote:
  16. > >Vlastimil Adamovsky wrote:
  17. > >>
  18. > >>  1) you cannot cast member function to non-member. It is nonsense
  19. > >You can if the method is declared as static:
  20. > >class TTest {
  21. > >public:
  22. > >       static void MemberFunction(int iVal)
  23. > >       {
  24. > >               printf("[%d]\n", iVal);
  25. > >       };
  26. > >};
  27. > It is correct. But "static member function" is not a real member
  28. > function. It is some kind of "convenience to call it so.
  29.  
  30. Yes, that is true.  The programmer has to be aware of the problems that 
  31. can occur using statics in a class.  It may be better to use friend 
  32. functions instead.  I have used statics on ocassion, but I sure didn't 
  33. want to.  Yet, I needed to be able to pass a function pointer to some 
  34. functions that used those methods.  It works, but it has its 
  35. limitations.  Like not being able to call other non-static 
  36. methods/members.
  37.  
  38. I chose to do this because I wanted the functions to be bundled with 
  39. the class.  It was limiting, but it fit for the application.  However, 
  40. if there would have been a better way, I sure would like to know about 
  41. it. <g>
  42.  
  43. -- 
  44. Scott Jibben, Jibben Software
  45. Galactic Overlord & Mines of Gorr BBS Door Games
  46. -----------------------------
  47. [EMAIL] sjibben@usinternet.com
  48. [WWW] http://www.usinternet.com/jsw
  49. [FTP] ftp.europa.com /outgoing/DOORS/jibben
  50. [FTP] ftp.cts.com /pub/dferber/jibben
  51. [FIDO] 1:282/115             [BBS] 612-379-8272 (10 USR 28.8 Couriers)
  52. [VOICE] 612-757-5626         [FAX] 612-757-8687
  53.  
  54.